package sia.knights;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import sia.knights.config.KnightConfig;

public class KnightMain {

  public static void main(String[] args) throws Exception {

    testAnnotationApplication();
  }


  private  static void testAnnotationApplication(){
      ApplicationContext context =  new AnnotationConfigApplicationContext(KnightConfig.class);
      Knight knight = (Knight)context.getBean(Knight.class);
      Quest quest = (Quest)context.getBean("quest");
      knight.embarkOnQuest();
  }

  private  static void testClassPathApplication(){
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/knight.xml");
    Knight knight = (Knight)context.getBean(Knight.class);
    Quest quest = (Quest)context.getBean("quest");
    knight.embarkOnQuest();

  }


  private  static void testFileApplication(){
    ApplicationContext context = new FileSystemXmlApplicationContext("D:/knight.xml");
    Knight knight = (Knight)context.getBean("knight");
    Quest quest = (Quest)context.getBean("quest");
    knight.embarkOnQuest();
  }


}
